<?php

namespace app\admin\model\technician;

use think\Model;


class Technician extends Model
{

    

    

    // 表名
    protected $name = 'technician';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;


    // 追加属性
    protected $append = [
        'technician_gender_text',
        'education_status_text',
        'recommend_status_text',
        'technician_status_text',
        'is_telephone_text',
        'is_join_store_text',
//        'serve_time_text',
        'is_check_text'
    ];
    

    
    public function getTechnicianGenderList()
    {
        return ['0' => __('Technician_gender 0'), '1' => __('Technician_gender 1')];
    }

    public function getEducationStatusList()
    {
        return ['0' => __('Education_status 0'), '1' => __('Education_status 1'), '2' => __('Education_status 2'), '3' => __('Education_status 3'), '4' => __('Education_status 4'), '5' => __('Education_status 5')];
    }

    public function getRecommendStatusList()
    {
        return ['1' => __('Recommend_status 1'), '2' => __('Recommend_status 2')];
    }

    public function getTechnicianStatusList()
    {
        return ['1' => __('Technician_status 1'), '2' => __('Technician_status 2')];
    }

    public function getIsTelephoneList()
    {
        return ['0' => __('Is_telephone 0'), '1' => __('Is_telephone 1')];
    }

    public function getIsJoinStoreList()
    {
        return ['0' => __('Is_join_store 0'), '1' => __('Is_join_store 1')];
    }

    public function getIsCheckList()
    {
        return ['0' => __('Is_check 0'), '1' => __('Is_check 1')];
    }


    public function getTechnicianGenderTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['technician_gender']) ? $data['technician_gender'] : '');
        $list = $this->getTechnicianGenderList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getEducationStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['education_status']) ? $data['education_status'] : '');
        $list = $this->getEducationStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getRecommendStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['recommend_status']) ? $data['recommend_status'] : '');
        $list = $this->getRecommendStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTechnicianStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['technician_status']) ? $data['technician_status'] : '');
        $list = $this->getTechnicianStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsTelephoneTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_telephone']) ? $data['is_telephone'] : '');
        $list = $this->getIsTelephoneList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsJoinStoreTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_join_store']) ? $data['is_join_store'] : '');
        $list = $this->getIsJoinStoreList();
        return isset($list[$value]) ? $list[$value] : '';
    }


//    public function getServeTimeTextAttr($value, $data)
//    {
//        $value = $value ? $value : (isset($data['serve_time']) ? $data['serve_time'] : '');
//        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
//    }


    public function getIsCheckTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_check']) ? $data['is_check'] : '');
        $list = $this->getIsCheckList();
        return isset($list[$value]) ? $list[$value] : '';
    }

//    protected function setServeTimeAttr($value)
//    {
//        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
//    }

    public function technicianlabel()
    {
        return $this->belongsTo('app\admin\model\technician\Technicianlabel', 'technician_label', 'id', [], 'LEFT')->setEagerlyType(0);
    }

  public function store()
  {
    return $this->belongsTo('app\admin\model\store\Store', 'store_id', 'store_id', [], 'LEFT')->setEagerlyType(0);
  }
}
